from django.contrib import admin
from .models import *
# Register your models here.


class AticleAdmin(admin.ModelAdmin):
    def get_list_display(self, request):
        fields = [f.name for f in self.model._meta.fields]
        exclude_fields = ['create_at', 'update_at', 'content']
        return [field for field in fields if field not in exclude_fields] + ['display_tags']

    def display_tags(self, obj):
        return ", ".join([tag.name for tag in obj.tags.all()])
    display_tags.short_description = '标签'


admin.site.register(Article, AticleAdmin)
admin.site.register(Category)
admin.site.register(Tag)
